package com.yql.commonextend.middleware.rocketmq;

//import com.aliyun.openservices.ons.api.Message;
//import com.aliyun.openservices.ons.api.ONSFactory;
//import com.aliyun.openservices.ons.api.Producer;
//import com.aliyun.openservices.ons.api.PropertyKeyConst;
//import com.aliyun.openservices.ons.api.order.*;
import com.yql.commonextend.config.MqConfig;

import java.util.Properties;

/**
 * @Author: XXX
 * @Description: XXX
 * @Date: 2021/7/22
 **/
public class MQOrderConsumer {

    /**
     *   accessKey: LTAI4G9zY9dtjrkX9m9KX5NX
     *   secretKey: mFgpfdNWmULnl3qEwMnm8CEZ9j7Zxf
     *   nameSrvAddr: http://MQ_INST_1093588360087422_BXsAfShQ.mq-internet-access.mq-internet.aliyuncs.com:80
     *   instanceId: MQ_INST_1093588360087422_BXsAfShQ
     *   sendMsgTimeoutMillis: 3000
     *   normalTopic: topic_yql_normal
     *   normalGroupId: GID_normal_default
     *   orderTopic: topic_yql_order
     *   orderGroupId: GID_order_default
     *   partOrderTopic: topic_yql_part_order
     *   partOrderGroupId: GID_part_order_default
     *   transTopic: topic_yql_trans
     *   transGroupId: GID_trans_default
     */
//    public static void consume(String[] args) {
//        Properties consumerProperties = new MQProperties().getMQProperties();
//
//        consumerProperties.setProperty(PropertyKeyConst.GROUP_ID, MqConfig.getOrderGroupId());
//        consumerProperties.setProperty(PropertyKeyConst.NAMESRV_ADDR, "http://MQ_INST_1093588360087422_BXsAfShQ.mq-internet-access.mq-internet.aliyuncs.com:80");
//        OrderConsumer consumer = ONSFactory.createOrderedConsumer(consumerProperties);
//        consumer.subscribe("topic_yql_part_order", "test",  new MessageOrderListener() {
//            @Override
//            public OrderAction consume(final Message message, final ConsumeOrderContext context) {
//                System.out.println(message);
//                return OrderAction.Success;
//            }
//        });
//        consumer.start();
//        System.out.println("Consumer start success.");
//        //等待固定时间防止进程退出
//        try {
//            Thread.sleep(200000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//    }
}

